<%@ page contentType="text/html; charset=UTF-8" %>
<%@page import="com.gljx.constant.Constant"%>
<%@page import="org.apache.shiro.SecurityUtils"%>
<%@page import="org.apache.shiro.session.Session"%>
<%
	String ajaxPath = request.getContextPath();
	Session userSession = SecurityUtils.getSubject().getSession();
	String userCompanyID = (String)userSession.getAttribute(Constant.CompanyId_session);
%>
<html>
<style>
	.panel .window{padding: 0}
	.hide{display: none}

    .messager-icon, .messager-warning {
        display: none
    }

    .sq a {
        color: #57a0ff
    }
	.test-1::-webkit-scrollbar {/*滚动条整体样式*/
		width: 5px;     /*高宽分别对应横竖滚动条的尺寸*/
		height: 2px;
	}
	.test-1::-webkit-scrollbar-thumb {/*滚动条里面小方块*/
		border-radius: 3px;
		-webkit-box-shadow: inset 0 0 1px rgba(0,0,0,0.2);
		background: #535353;
	}
	.test-1::-webkit-scrollbar-track {/*滚动条里面轨道*/
		-webkit-box-shadow: inset 0 0 5px rgba(0,0,0,0.2);
		border-radius: 2px;
		background: #EDEDED;
	}

	/*- scrollbar -*/
	::-webkit-scrollbar {
		width: 14px;
		height: 12px;
	}
	::-webkit-scrollbar-thumb{
		background-color: #999;
		-webkit-border-radius: 12px;
		border-radius: 12px;
	}
	::-webkit-scrollbar-thumb:vertical:hover{
		background-color: #666;
	}
	::-webkit-scrollbar-thumb:vertical:active{
		background-color: #ff666d;
	}
	::-webkit-scrollbar-button{
		display: none;
	}
	::-webkit-scrollbar-track{
		background-color: #f1f1f1;
	}
</style>
<body >


<div id="ajaxJSP_company_window_div" class="easyui-window user_set_windows" title="选择公司"
	 data-options="modal:true,closed:true,collapsible:false,minimizable:false,maximizable:false,iconCls:'icon-save',top:120,
				onClose: function () {
						document.body.style.overflow = 'visible'; //显示滚动条
				}"
	 style="width:500px;height:270px;display:none">
    <div style="height:268px;width:488px">
		<table id="ajaxJSP_company_list_table"toolbar="#ajaxJSP_company_bar">
		</table>
		<div id="ajaxJSP_company_bar"style="background-color: #f5f5f5;padding:5px 10px">
			<label style="margin:5px 5px 0 10px ;font-size:14px;float:left">公司名称：</label>
			<input type="text" class="easyui-validatebox" placeholder="请输入公司名称" id="company_name_input"
                   style="width:150px;height:27px;margin-right:20px;border: none;padding: 0"/>
			<input type="button" value="立即搜索" onclick="ajaxJSP_CompanyPage()"
                   style="cursor:pointer;background-color: #54a0ff;border: none;color: #fff;border-radius:20px;padding:5px 20px;width: 100px;height: 27px"/>
		</div>
	</div>
</div>
<div id="activiti_img_set_window_div" class="hide"
     style="width:900px;height:600px;overflow: hidden;">
</div>
</body>
</html>


<!-- css资源 -->
<link rel="stylesheet" type="text/css" href="<%=ajaxPath%>/easyUI1.4.1/themes/default/easyui.css">
<!--EasyUI的js包 -->
<script type="text/javascript" src="<%=ajaxPath%>/easyUI1.4.1/jquery.easyui.min.js"></script>
<!-- 本地语言 -->
<script type="text/javascript" src="<%=ajaxPath%>/easyUI1.4.1/locale/easyui-lang-zh_CN.js"></script>
<%--阻止浏览器后退事件--%>
<script type="text/javascript" src="<%=ajaxPath%>/common/stopBrowerBack.js"></script>
<script>
    var right_company_flag = false;
    if(typeof ($bottom_companyId) != 'undefined'){
    var oldUserCompanyID = window.parent.frames['bottomFrame'].$bottom_companyId;
    if(oldUserCompanyID != '<%=userCompanyID%>' && '<%=userCompanyID%>' !=null){
        window.parent.frames['bottomFrame'].location.reload();
    }
    }
    /* 部分参数仅测试时展示 */
    $.ajaxSetup({
        contentType:"application/x-www-form-urlencoded;charset=utf-8",
        complete:function(XMLHttpRequest,textStatus){
        },
        statusCode: {
            400: function() {
                $.messager.progress('close');
                $.messager.alert('提示','请刷新页面重试 400 !','warning');
            },
            401: function() {
                $.messager.progress('close');
                $.messager.alert('提示','登录超时!','warning');
            },
            404: function() {
                $.messager.progress('close');
                $.messager.alert('提示','没有此服务!','warning');
            },
            504: function() {
                $.messager.progress('close');
                $.messager.alert('提示','服务器没有响应!','warning');
            },
            500: function() {
                $.messager.progress('close');
                $.messager.alert('提示','请刷新页面重试!','warning');
            },
            507: function() {
                $.messager.progress('close');
                $.messager.alert('提示','权限不足!','warning');
            },
            510: function() {
                $.messager.progress('close');
                $.messager.alert('提示','非法字符!','warning');
            },
            520: function() {
                $.messager.progress('close');
                $.messager.alert('提示','当前账户重复登录!','warning');
            }
        }
    });

    //打开公司搜索窗口
    function ajaxJSP_searchCompany(){
        document.body.style.overflow = "hidden"; //隐藏滚动条
        //清除用户checked项
        //$('#ajaxJSP_company_list_table').datagrid('clearSelections');
        $("#ajaxJSP_company_window_div").attr("style","width:500px;height:270px;");
        $('#ajaxJSP_company_window_div').window('open');
        //解决滚动条导致的弹窗错位问题
        $('#ajaxJSP_company_window_div').window('center');
        ajaxJSP_CompanyPage();
    }
    //公司分页查询
    function ajaxJSP_CompanyPage(){
        if(right_company_flag){
            var patrn=/[!#@$%^&*()_+<>?:"{},\/;'[\]]/;
            if(patrn.test($('#company_name_input').val())){
                $.messager.alert('提示','请不要使用非中文符号!');
                return true;
            }
            //保留页码查询
            $('#ajaxJSP_company_list_table').datagrid('reload',{
                company: $('#company_name_input').val()
            });
        }else{
            $("#ajaxJSP_company_list_table").datagrid({
                url: '<%=ajaxPath%>/DrivingSys/common/company.action',  //数据来源
                //冻结列
                columns:[[
                    { field: 'ck', checkbox: true, width: '30' },  //复选框
                    {field:'companyName',title:'公司名称',width:420,align:'center'}
                ]],
                fitColumns:false,//自适应宽度，占满,不能和冻结列同时设置成true
                fit:true,//充满屏幕
                striped:true,   //斑马线效果
                rownumbers:true,            //显示行号
                idField:'fid',    //主键列
                singleSelect:true,          //是否单选
                cache:true,				//关闭缓存
                method:'post',
                pagination:true,
                pageList:[10,20,50,100],//每页行数选择列表
                pageSize:20, //设置默认初始的每页行数rows
                pageNumber:1,//设置默认初始的页码page
                multiSort:true,
                onClickRow : function(index, row){
                    $.messager.confirm('提示', '是否为将组织设置为<b>'+row.companyName+'</b>?', function (r) {
                        if (!r) {
                            return;
                        }
                        var selRow = $('#ajaxJSP_company_list_table').datagrid('getSelections')[0];

                        //设置底部的公司
                        window.parent.parent.frames['bottomFrame'].setCompany(row.fid,row.companyName,row.flongnumber);
                        //关闭公司选择框
                        $('#ajaxJSP_company_window_div').window('close');

                        //重置顶部个人消息。
                        window.parent.parent.frames['topFrame'].top_setMessage_Flag(true);

                        location.href = "<%=ajaxPath%>/DrivingSys/right.action";
                    });
                },
                onLoadSuccess:function(){
                    right_company_flag = true;
                    $('#ajaxJSP_company_list_table').datagrid('clearSelections');
                },loadMsg:'请稍候...'
                //关闭回调

            });
        }
    }

    var isSuccess = 1;
    /*lcx  form 校验*/
    $("form").bind("submit", function () {
        if ($('#fbizdate_bind').val() == "") {
            alert('业务日期项不能为空 ！')
            return false;
        }

        isSuccess = 1;
        $('.is_click').each(function () {
            if ($(this).val().trim() == "") {
                isSuccess = 0;
            }
        });

        if (isSuccess == 0) {
            alert('必填项不能为空 ！')
            return false;
        }
        //放行不需要拦截的
        if ($('.is_click').length == 0) {
            isSuccess = 0;
        }
    })

    //防止表单重复提交
    function StopRepeat() {
        if (isSuccess == 1) {
            $("input[type='submit']").attr("disabled", "disabled");
            $("input[type='button']").attr("disabled", "disabled");
        }
    }

    //没有使用 $("form").bind("submit", function () { 调用
    function StopRepeat2() {
        $("input[type='submit']").attr("disabled", "disabled");
        $("input[type='button']").attr("disabled", "disabled");
    }

    if ($('#alertType').val() == 'bc' || $('#alertType').val() == 'qd') {
        console.log('1.' + $('#alertType').val())
        editAlert()
    }

    //计算最大的行
    function CalculateMaxNum(tableid) {
        return $("#" + tableid).find("tr").length;
    }

    //重新排序
    function reorder(tableid) {
        $('.fseq').each(function (i) {
            $(this).val(i + 1)
        })
    }
    /**
     * a
     * @param fnumberName 创建流程时单据的名称
     * @param fnumber	  创建流程时单据的编号
     * @returns {boolean}
     */
    //查看流程图
    function lookActivitiImg(fnumberName,fnumber){
        if(fnumber == null || fnumber == undefined || fnumber == 'undefined')
        {
            return false;
        }else{
            var content = '<iframe src="' + '<%=ajaxPath%>/DrivingSys/activiti/openActivitiImagePage.action?fnumberName='+fnumberName+'&fnumber='+fnumber + '"scrolling="yes" frameborder="0" width="100%" height="95%" style="overflow:auto;"></iframe>';
            /*$('#activiti_img_set_window_div').css('display','block');
            console.log("11");*/

            document.body.style.overflow = "hidden"; //隐藏滚动条

            $("#activiti_img_set_window_div").removeClass('hide');
            $('#activiti_img_set_window_div').dialog({
                content: content,
                minimizable:true,
                minimizable:true,
                maximizable: false,
                resizable: true,
                title:'流程详情',
                border: false,
                resizable: true,//定义对话框是否可调整尺寸。
                maximized: false,//默认最大化
                modal: true,
                //关闭回调
                onClose: function () {
                    document.body.style.overflow = "visible"; //显示滚动条
                }
            });
            $('#activiti_img_set_window_div').dialog('center');
        }
    }

    function alert(str) {
        //alert(str)
        $.messager.alert('提示', str, 'info', function (r) {
            $('.window-mask').fadeOut()
        });
    }

    function showAlert(msg, href) {
        $('#againstAuditsubmit').attr('disabled', 'disabled');
        $('#auditsubmit').attr('disabled','disabled');
        $("input[type=button]").attr('disabled','disabled');
        $.messager.show({
            title: '提示',
            msg: msg,
            timeout: 1200,
            width: 300,
            height: 180,
            showType: 'slide'
        })
        setTimeout("parent.closeSelectCard()","1300")

        //window.setTimeout("window.location='<%=ajaxPath%>/DrivingSys/" + href + "'", 1000);
    }


    $('.del').live('click',function(){
        $('.window-mask').fadeToggle()
    })
    $(".sure").live('click', function () {
        /*$(".tip").fadeOut(100);*/
        $('.window-mask').fadeOut()
    });
    $(".cancel").live('click',function(){
        /*$(".tip").fadeOut(100);*/
        $('.window-mask').fadeOut()
    });

    function editAlert() {
        console.log("---------")
        $.messager.show({
            title: '提示',
            msg: "保存成功",
            timeout: 1200,
            width: 300,
            height: 180,
            showType: 'slide'
        })
        setTimeout("parent.closeSelectCard()","1300")
    }

	/* //阻止浏览器后退事件
	 function stopBrowerBack() {
	 if (window.history && window.history.pushState)
	 {	　　$(window).on('popstate', function () {
	 window.history.pushState('forward', null, '#');
	 window.history.forward(1);
	 });
	 }
	 window.history.pushState('forward', null, '#'); //在IE中必须得有这两行	　　
	 window.history.forward(1);
	 }*/
    //单击选中复选框
    $(".tablelist tr").live('click',function(){
        if (this.rowIndex == 0) return;
        if ($(this).find("td:eq(0) input[type='checkbox']:eq(0)").attr("checked") == 'checked') {
            //已选中的行取消选中
            $(this).find("td:eq(0)  input[type='checkbox']:eq(0)").attr("checked", false);
        } else {
            //未选中的行，进行选中
            $(this).find("td:eq(0) input[type='checkbox']:eq(0)").attr("checked", true);
        }

    });
    //阻止复选框进行冒泡事件
    $("tr input[type='checkbox']").live('click',function(event){
        event.stopPropagation();
    });

    function gotoSelectCard(_this,url) {
        $this = $(_this)
        var menuId = get_Caed_id()
        var title_head = $('.placeul li:nth-child(2) a').html()

        if (typeof($this.attr('funurl')) == "undefined"){
            url = url
        }else {
            url = $this.attr('funurl');
        }
        var title = title_head + '-'+ $this.text();
        if(title.length > 10){
            title = title_head+'-详情'
		}
        parent.goToMessage(menuId,title,url)
        var conentHeight = parent.$('.tab-content').height() + 0.1 + 'px'
        parent.$('.tab-content').css('height',conentHeight)
    }



    //
    function get_Caed_id(){
        var n = 0;
        var m = 99999;
        var random = Math.floor(Math.random()*(m-n+1)+n);

        //$('#caed_id').val(random)

		return random;
    }

</script>